/* Name: PauseBtn
 * Author: Tom Dickman
 * Date: 5-29-12
 * Description: Button used to pause the game
 * Revisions: See Subversion logs at http://code.google.com/p/software-engineering-2012/source/list
 */

import java.awt.Graphics2D;

public class PauseBtn extends Button {
	private int radius;
	private Sprite sprite;
	
	// Creates a pause button at the given location, and with the given radius
	public PauseBtn(int px, int py, int pRadius) {
		super(px, py, pRadius);
		Game.create((Item)this, 1000000); // Needed for update, draw, and destroy
		colType = COL_NONE; // Needed for collision checking
		radius = pRadius;
	}
	
	// Called when the button is pressed - plays the proper sound / visual effect
	protected void pressed() {
		if (!GameScreen.gameComplete && !GameScreen.gameFailed) {
			Sound.effect(Sound.EFFECT_CLICK);
			Game.isPaused = true;
		} else {
			selected = false;
		}
	}
	
	// Called when the button is released - plays the proper sound / visual effect
	protected void released() {
		Sound.effect(Sound.EFFECT_CLICK);
		Game.isPaused = false;
	}
	
	// Called whenever a new frame is drawn on the screen - draws the button
	public void draw() {
		Graphics2D gh = Game.getGraphicsHandle();
		if (selected) { // Sets the proper sprite
			sprite = Sprite.load("/sprites/Buttons/play.png");
		} else {
			sprite = Sprite.load("/sprites/Buttons/pause.png");
		}
		sprite.draw(gh, x, y);
	}
	
	public void update() {updateBtn();}
	public void leftMousePress() {leftMousePressBtn();}
	public void leftMouseRelease() {leftMouseReleaseBtn();}
}